from config import conf
from os.path import join, exists
import pandas as pd

MODEL_DIR = conf.get('dir', 'model_save_dir')


def load_model_rs(model_name, version_id, file_name=None):
    """model in  ['BertSentiEntity', 'BertSentiment']"""
    assert model_name in ['BertSentiEntity', 'BertSentiment', 'bert_one_entity', 'BertSentiEntityMultilayer',
                          'BertMultiClass', 'multi_class_cross1', 'multi_class_cross2', 'BertSentiEntity_cross',
                          'multi_class_cross_roberta','senti_entity_goodremove']
    if file_name == None:
        file_name = 'raw_rs.csv'
    path = join(MODEL_DIR, model_name, 'version%s' % version_id, 'data', file_name)
    if exists(path):
        df = pd.read_csv(path)
    else:
        raise Exception('file %s not exists' % (path))
    return df


if __name__ == '__main__':
    df = load_model_rs(model_name='BertSentiment', version_id=2)
    print(df)
    df = load_model_rs(model_name='BertSentiEntity', version_id=1, file_name='raw_val_rs.csv')
    print(df)
